<?php
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
// Ricardo Galli <gallir at uib dot es>.
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".

if($_POST['xmlhttp']){
	include_once('Smarty.class.php');
	$main_smarty = new Smarty;
	
	include('config.php');
	include(mnminclude.'html1.php');
	include(mnminclude.'ts.php');
	include_once(mnminclude.'link.php');
	include_once(mnminclude.'group.php');
	include(mnminclude.'tags.php');
	include(mnminclude.'smartyvariables.php');
	
	$grp_id = strip_tags($_POST['grp_id']);
	$grp_name = strip_tags($_POST['grp_name']);
	$grp_privacy = strip_tags($_POST['grp_privacy']);
	$grp_desc = strip_tags($_POST['grp_desc']);
	$grp_tags = strip_tags($_POST['grp_tags']);
	if ($grp_name == '') {
		echo 'noname';
		die();
	}
	if ($grp_desc == '') {
		echo 'nodesc';
		die();
	}
	$group = new Group();
	$group->id = $grp_id;
	$group->read();
	$group->name = $grp_name;
	$group->desc = $grp_desc;
	$group->privacy = $grp_privacy;
	$group->store();
	
	$link = new Link();
	$link->id = $group->linkid;
	$link->read();
	$link->title = strip_tags(trim($group->name));
	$link->title_url = makeUrlFriendly($link->title);
	$link->tags = tags_normalize_string(strip_tags(str_replace('，',',',trim($_POST['grp_tags']))));
	$link->content = strip_tags($link->title, Story_Content_Tags_To_Allow);
	$link->content = str_replace("\n", "<br />", $link->content);
	$link->link_summary = utf8_substr(strip_tags($link->content, Story_Content_Tags_To_Allow), 0, StorySummary_ContentTruncate - 1);
	$link->link_summary = str_replace("\n", "<br />", $link->link_summary);		
	$link->store();
			
	tags_insert_string($link->id, $dblang, $link->tags);
	
	header('Content-Type: text/plain; charset=UTF-8');
	//echo $info;
	echo ('success:');
	die();
}



?>
